home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / move32.com / TT_32BIT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-06-04  |  7.4 KB  |  160 lines

  1. {$A+,D-,E-,F+,I-,N-,O-,R-,S-,V-}
  2. UNIT TT_32Bit;
  3.  
  4. (*
  5. REVISION    :  0.1ß
  6. LAST UPDATE :  31 May, 1989
  7. PROGRAMMER  :  Thomas A. Toth Jr.
  8. CompuServ ID:  [71071,372]
  9.  
  10. Copyright(c) 1989, All rights reserved.   Synergy Software Developers.
  11.    Any Object and Borland International '.TPU' files (for this version)
  12.    are released to the Public Domain for the betterment of mankind.  These
  13.    files may be distributed (free of charge, though!!) to others, but all
  14.    files MUST be left unmodified (if you happen to find a fixable bug, fix
  15.    it, make note of it at the top of this file, upload a new copy onto the
  16.    BPROGA forum on CompuServ (Turbo 5 DL), and try to contact me!!!).
  17.    If any of these routines are used in any distributable applications, I
  18.    expect that you will give me credit on your programs' "log-on" screen
  19.    or in the opening pages of your documentation!  .ASM Source-code for
  20.    Move32.obj will be made available at a later date.
  21.  
  22.    * All code uploaded by myself in the future can be found by entering
  23.    'TT_Lib' at the 'keyword' prompt when entering the 'Browse' option
  24.    in the BPROGA forum (turbo 5 DL) on CompurServ!!
  25.  
  26. DESCRIPTION:
  27.   A small Unit to give the programmer auto-detecting routines to utilize the
  28.   32-bit data bus of the 80386/80486 micro-processors, when pressent.  If one
  29.   of these processors is NOT in use, these routines use 16 XFers, stil making
  30.   them a good deal faster than the Turbo Move() proc when moving large blocks
  31.   of information.  All procedures were coded in assembler for optimal speed
  32.   and was developed using Borland's Turbo Assembler, version 1.0.
  33.  
  34.   Right now, there is only 2 procedures and one global 'variable' decalred
  35.   public.  As time marches on, and as I can drift aside from the financially
  36.   profitable programming endeavors, it will contonue to grow with more
  37.   features.
  38.  
  39.   This unit the first of a large series of libraries and utilities for the
  40.   programming community at large.  Most of the TP Unit filenames will be
  41.   prefaced with 'TT_' (so you can remember me!).  A good deal of the routines
  42.   are modified copies of some code that serves as the kernal for an operating
  43.   enviroment known as 'TOE' (developed by myself) which is used by all
  44.   applications being developed by our company.  'TOE' is basically an MS-DOS
  45.   version of an OS/2 DLL.  A large portion of it is a kind of a text-based
  46.   Presentation Manager.  Once the PC world comewhat settles on a standard
  47.   multi-tasking (and hopefully mutli-user) operating system, I plan to mass-
  48.   market 'TOE'.  So keep an eye open a couple years from now.  A number of
  49.   programmers accross the country are now using TOE to develope some of their
  50.   applications, and LOVE it.  You may be making 'calls' to TOE one day too!
  51.  
  52.  
  53. AKNOWLEDGMENTS:
  54.   The routine called in the initialization section uses a concept borrowed
  55.   from Mark Boler's CpuInfo function found in CPUTP.ARC in the Borland
  56.   Program Library A (Turbo 5.0 Source code).  Thanks to folks like Mr. Boler,
  57.   Kim Kokkonnen and many others, I have learned more about the joys, tricks
  58.   and traps associated with systems-level programming through studying and
  59.   devouring their source-code that has been uploaded there.
  60.  
  61.  
  62. NOTES:
  63.   - MAKE SURE that TT_32Bit is 'Used' before any other unit that may call
  64.   either of the Move32?() procs in their 'Initialization' routine(s)!!!!
  65.   You won't send your machine to lunch , or anything silly like that, but
  66.   you will instead only get 16-bit throughput because TT_32Bit has not yet
  67.   been initialized!
  68.  
  69.   - Both of these routines are most effective on Xfer's of more than 1-2K,
  70.   this especially applies to Move32o() because of the normalizing of pointers
  71.   and 'range checking'.  The exception would be in cases where you have xfers
  72.   that may overlap themselves when using Turbo's Move(), you can use Move32o()
  73.   in its place to avoid that tragic event from occuring!
  74.  
  75.   - Please note the compiler directive {$O-} above; it is vitally important to
  76.   remember that this unit should NOT be overlayed due to the fact that it has
  77.   an initialization section (nothing fatal in its' own right, but...) and the
  78.   fact that this is a routine designed for optimal performance, Overlays are
  79.   not!
  80.  
  81. If you have any ideas, criticisms, etc., my CompuServ ID is at the top of
  82. this file.  Would love to hear from somebody, shit...anybody!  Keep your eyes
  83. open for more code from us in the near future!
  84.  
  85. [=Thom=]
  86. Synergy Software
  87. 'Dedicated to a Bug-free America!'
  88. ________________________________________________________________________________
  89.  
  90. The routines provided (with some notes) are:
  91.  
  92.     PROCEDURE Check32Bit;      { **** Not decalred 'PUBLIC' **** }
  93.         - Sets the boolean variable named 'Has386' to TRUE if a
  94.          32-bit micro-processor is present in the system.  It is
  95.          automatically called in the 'INIT' section of the TT_Moves
  96.          unit.  'Has386' is declared 'public' by being declared in
  97.          INTERFACE section so that you can access it also.
  98.  
  99.     PROCEDURE Move32(VAR Source, Dest; BytesToMove : WORD);
  100.         - This is the 'low-level' or kernal routine for the 32-bit
  101.          replacement for Move().  If a 32 bit processor is in use,
  102.          Move32() will process that Xfer utilizing REP MOVSD (32 bits).
  103.          Otherwise, REP MOVSW is used (16-bits).
  104.         - Move32() automatically adjusts the 'BytesToMove' argument for
  105.          'DWORD' (or 'WORD') alignment internally.
  106.         - No checks for memory overwrite or Segment over-run are made
  107.           by this routine.  It is your responsibility to insure that the
  108.          Offset addresses for both 'Source' & 'Dest' plus 'BytesToMove'
  109.          is less than $FFFF, as well as insuring that 'Dest' is at a
  110.          memory location below or at Source+BytesToMove.  These same
  111.          rules are being followed if you use the Turbo Move() proc.
  112.  
  113.     PROCEDURE Move32o(VAR Source, Dest; BytesToMove : WORD);
  114.         - This is basically a higher level 'pre-processor' to Move32().
  115.          The only difference is that 'Move32o()' first normalizes both
  116.          pointers to insure that you won't have any 'segment over-run';
  117.          so if the pointer pushed on the stack that was assigned by
  118.          Turbo for 'Source' is $2A70:$F10A, it will be 'normalized' to
  119.          $3980:$000A, allowing us move up $FFF5 bytes (in this case),
  120.          and not 'wrap' around back to $3980:$0000.
  121.         - Along with both pointers being normalized, a check is done to
  122.          insure that the first byte moved from 'Source' to 'Dest' does
  123.          not lie some between 'Source' and 'Source'+'BytesToMove'. If
  124.          this is the case, then Move32o() will move this data starting
  125.          at the end of each array.
  126.         An example would be:
  127.              Move32o(Mem[$b800:0000],Mem[$b800:00A0],3840);
  128.          As you can see, the first 160 bytes would be replicated
  129.          throughout that memory array for the next 3680 bytes,
  130.          IF we were to use either Move() or my Move32() procedures.
  131.          Move32o() looks for this sort of overlap, and will move it
  132.          without error by starting at the end of both 'Source' & 'Dest'.
  133.  
  134. *)
  135.  
  136. { ░░▒▒▓▓██ The} INTERFACE {Section ██▓▓▒▒░░ }
  137.  
  138. CONST
  139.   Has386  : BOOLEAN = FALSE;
  140.  
  141.  
  142. PROCEDURE Move32(VAR Source, Dest; BytesToMove : WORD);
  143.  
  144. PROCEDURE Move32o(VAR Source, Dest; BytesToMove : WORD);
  145.  
  146.  
  147. { ░░▒▒▓▓██ The} IMPLEMENTATION {Section ██▓▓▒▒░░ }
  148.  
  149. {$L Move32.obj}
  150.  
  151. procedure Check32Bit; external;
  152. Procedure Move32; external;
  153. Procedure Move32o; external;
  154.  
  155.  
  156. { ░░▒▒▓▓██ The Initialization Section ██▓▓▒▒░░ }
  157. BEGIN
  158.   Check32Bit;   { Initializes Typed Const named 'Has386' for later use.}
  159. END.  { INIT }
  160.